<template>
    <div class="bg-Score">
        <div v-if="scoreList.length>0">
            <div class="titleBox">
                <i></i>
                <span>考试成绩</span>
            </div>
        <div style="overflow:hidden"  >
            <div class="count-list fl" v-for="( item, index) in  scoreList" :key='index'>
               <div class="fl count-list-left">
                   <span>{{item.score}}分</span>
               </div>
               <div class="fl count-list-right">
                   <p class="count-list-right-boder" :title="item.paperName">{{item.paperName}}</p>
                   <p class="count-list-right-time">试卷时长: {{item.timeLength}}分钟</p>
               </div>
            </div>
        </div>
        </div>
        <div v-else class="table" >
            <div class="titleBox">
                <i></i>
                <span>考试成绩</span>
            </div>
            <div  class="empty">
                <img src='../../../assets/images/empty.png'/>
                <p>暂无数据</p>
            </div>
        </div>

        <div class="table">
            <div class="titleBox">
                  <i></i> <span>平时成绩</span>
            </div>
            <el-table  :data="tableData" style="width: 95%" class="tablist">
                <el-table-column  type="index" label="序号" width="100"></el-table-column>
                <el-table-column  prop="chapterName"  label="章节名称" >  </el-table-column>
                <el-table-column  prop="typeMessage"  label="类型" >  </el-table-column>
                <el-table-column  prop="score"  label="得分" >  </el-table-column>
            </el-table>
        </div>
    </div>
</template>

<script>
    export default {
        data() {
             return {
                 tableData:[],
                 //成绩数量
                 scoreList:[],
                 colorList:['#58a8e8','#42bbab','#7c87c2']
             }
        },
        created() {
             this.courseId = this.$localstorage.getLocalStorage('setCourseId')
             this.init()
             this.secoe()
        },
        methods:{
            init(){
                let self = this
                self.$http.get('/tes/course/'+self.courseId+'/student/base-statistics').then(response => {
                    let res = response.data
                    if(res.code == '200'){
                        self.tableData = res.data
                    }else{
                        self.$message.error(res.message)
                    }
                })
            },
           //展示成绩
            secoe(){
                let self = this
                self.$http.get('/tes/course/'+self.courseId+'/student/exam-statistics').then(response => {
                    let res = response.data
                    if(res.code == '200'){
                        self.scoreList = res.data
                        this.$nextTick(item=>{
                            let Div = document.querySelectorAll('.count-list .count-list-left')
                            for(let i=0; i<Div.length; i++){
                                Div[i].style.background = self.colorList[i%self.colorList.length];
                            }
                        })
                    }else{
                        self.$message.error(res.message)
                    }
                })
            }

        }
    }
</script>

<style lang="scss" scoped>
    .bg-Score{
        width: 1200px;
        margin: 20px auto;
        .titleBox{
            height: 18px;
            position: relative;
            line-height: 18px;
            color: #385899;
            padding-left: 20px;
            font-weight: 700;
            margin-bottom: 10px;
            font-size: 16px;
                i{
                    width: 2px;
                    height: 15px;
                    position: absolute;
                    left: 0;
                    top: 3px;
                    background: #385899;
                    margin-right: 40px;
                }
        }
         .count-list{
                box-sizing: border-box;
                box-shadow: 0 0 12px #dedede;
                background: #fff;
                border-radius: 3px;
                padding: 20px 20px;
                margin:  10px 5px;
                color: #474747;
                line-height: 30px;
                font-size: 14px;
                width: 275px;
                height: 116px;
                margin-right: 24px;
                overflow: hidden;
                    &:nth-child(4n){
                         margin-right: 0px;
                    }
                    .count-list-left{
                        //  background: #474747;
                         border-radius: 50%;
                         width: 70px;
                         height: 70px;
                         &>span{
                             color: #fff;
                             font-size: 18px;
                             line-height: 70px;
                             text-align: center;
                             width: 70px;
                             display: inline-block
                         }
                    }
                    .count-list-right{
                        width: 160px;
                        .count-list-right-boder{
                            width: 160px;
                            margin-left: 10px;
                            word-break:keep-all;
                            white-space:nowrap;
                            overflow:hidden;
                            text-overflow:ellipsis;
                            border-bottom: 1px solid #e8e8e8;
                            padding-bottom: 10px;
                            margin-top: 10px;
                        }
                        .count-list-right-time{
                            width: 160px;
                            margin-left: 10px;
                            word-break:keep-all;
                            white-space:nowrap;
                            overflow:hidden;
                            text-overflow:ellipsis;
                            padding-bottom: 10px;
                            margin-top: 10px;
                        }
                    }
         }
         .table{
             background: #ffffff;
             margin: 20px 0;
             padding: 20px 0;
             box-shadow: 0 0 10px #e6e6e6;
                .tablist{
                   margin:  20px 30px
                }
         }
         .empty{
          padding:100px 0;
          text-align:center;
            p{
                padding: 15px 0;
                color: #666
            }
        }


    }

</style>
